<?php 
	include_once "../ini.php";
	include_once '../includes/function.php';
	include "../libraries/xl_hoa_don.php"; 
	$dt_xl_hoa_don = new xl_hoa_don;
	include "../libraries/xl_chi_tiet_hoa_don.php"; 
	$dt_xl_chi_tiet_hoa_don = new xl_chi_tiet_hoa_don;
	
	$_SESSION['ma_hoa_don']=$_POST['ma_hoa_don'];
	if (empty($_POST['ma_hoa_don']) || empty($_POST['ma_bao_ve'])) 
	{
		$_SESSION['msg'] = "Lỗi! Dữ liệu không hợp lệ, vui lòng kiểm tra lại.";
		$_SESSION['type_msg'] = "error";
		header('Location: '.$_SERVER['HTTP_REFERER']);
		exit;
	}
	if ($_POST['ma_bao_ve']!= $_SESSION["security_code"])
	{
		$_SESSION['type_msg'] = 'error';
		$_SESSION['msg'] = 'Lỗi! Mã bảo vệ không đúng! Vui lòng kiểm tra lại!';	
		header('Location: '.$_SERVER['HTTP_REFERER']);
		exit;
	}
	$hoa_don=$dt_xl_hoa_don->xem_hoa_don($_POST['ma_hoa_don']);
	if ($hoa_don==NULL)
	{
		$_SESSION['type_msg'] = 'error';
		$_SESSION['msg'] = 'Lỗi! Mã đơn hàng không tồn tại. Vui lòng kiểm tra lại!';	
		header('Location: '.$_SERVER['HTTP_REFERER']);
		exit;
	}
	$_SESSION['ma_hoa_don']='';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US" xml:lang="en">
<head>
<?php include '../widgets/head.php'?>
<script type="text/javascript" src="../js/jquery/external/jquery.simplyscroll-1.0.4/jquery.simplyscroll-1.0.4.min.js"></script>
<link rel="stylesheet" href="../js/jquery/external/jquery.simplyscroll-1.0.4/jquery.simplyscroll-1.0.4.css" media="all" type="text/css">
<script type="text/javascript" src="../js/jquery/external/stickytooltip/stickytooltip.js"></script>
<link rel="stylesheet" type="text/css" href="../js/jquery/external/stickytooltip/stickytooltip.css" />
</head>
<body>
<?php include '../widgets/header.php'?>
<div id="art-page-background-glare">
  <div id="art-page-background-glare-image">
    <div id="art-main">
      <div class="art-sheet">
        <div class="art-sheet-tl"></div>
        <div class="art-sheet-tr"></div>
        <div class="art-sheet-bl"></div>
        <div class="art-sheet-br"></div>
        <div class="art-sheet-tc"></div>
        <div class="art-sheet-bc"></div>
        <div class="art-sheet-cl"></div>
        <div class="art-sheet-cr"></div>
        <div class="art-sheet-cc"></div>
        <div class="art-sheet-body">
          <?php include '../widgets/nav.php'?>
          <div class="art-content-layout">
            <div class="art-content-layout-row">
              <div class="art-layout-cell art-sidebar1">
                <?php sidebar('left');?>
                <div class="cleared"></div>
              </div>
              <div class="art-layout-cell art-content">
                <div class="art-post">
                  <div class="art-post-tl"></div>
                  <div class="art-post-tr"></div>
                  <div class="art-post-bl"></div>
                  <div class="art-post-br"></div>
                  <div class="art-post-tc"></div>
                  <div class="art-post-bc"></div>
                  <div class="art-post-cl"></div>
                  <div class="art-post-cr"></div>
                  <div class="art-post-cc"></div>
                  <div class="art-post-body">
                    <div class="art-post-inner art-article">
                      <?php thong_bao();?>
                      <h2 class="art-postheader">Thông tin đơn hàng</h2>
                      <div class="line"> </div>
                      <div class="art-postcontent">
                        <table class="thong_bao_hoa_don" >
                          <tr>
                            <th class="thong_tin" colspan="5">ĐƠN HÀNG</th>
                          </tr>
                          <tr>
                            <td class="l"><strong>Ngày tạo: </strong><?php echo $hoa_don['ngay_tao']?></td>
                            <td colspan="2" class="r"><strong>Tổng tiền: </strong><?php echo number_format($hoa_don['tong_tien'],2,'.',',')?> <strong>VNĐ</strong></td>
                          </tr>
                          <tr>
                            <td class="l"><strong>Trạng thái: </strong>
                              <?php 
									if($hoa_don['trang_thai']==0) echo "Đơn hàng đã chấp nhận";
									if($hoa_don['trang_thai']==1) echo "Đã thanh toán và đang giao hàng";
									if($hoa_don['trang_thai']==2) echo "Đang giao hàng và nhận tiền thanh toán";
									if($hoa_don['trang_thai']==3) echo "Đã giao hàng";
								  ?></td>
                            <td colspan="2" class="r"><strong>Mã hóa đơn: </strong><span style="color:red"><strong><?php echo $hoa_don['ma_hd']?></strong></span></td>
                          </tr>
                          <tr>
                            <th class="thong_tin" colspan="5">NGƯỜI MUA</th>
                          </tr>
                          <tr>
                            <td class="l" colspan="3"><strong>Họ tên: </strong><?php echo $hoa_don['ho_ten']?></td>
                          </tr>
                          <tr>
                            <td class="l"><strong>Ngày sinh: </strong><?php echo $hoa_don['ngay_sinh']?></td>
                            <td colspan="2" class="l"><strong>Giới tính: </strong>
                              <?php if($hoa_don['gioi_tinh']) echo 'Nữ'; else echo 'Nam';?></td>
                          </tr>
                          <tr>
                            <td class="r"><strong>Số điện thoại: </strong><?php echo $hoa_don['dien_thoai']?></td>
                            <td colspan="2" class="l"><strong>CMND: </strong><?php echo $hoa_don['cmnd']?></td>
                          </tr>
                          <tr>
                            <td class="r"><strong>Email: </strong><?php echo $hoa_don['email']?></td>
                            <td colspan="2" class="r"><strong>Địa chỉ: </strong><?php echo $hoa_don['dia_chi']?></td>
                          </tr>
                          <tr>
                            <th class="thong_tin" colspan="3">NGƯỜI NHẬN</th>
                          </tr>
                          <tr>
                            <td class="l" colspan="3"><strong>Họ tên: </strong><?php echo $hoa_don['ho_ten_nguoi_nhan']?></td>
                          </tr>
                          <tr>
                            <td class="r"><strong>Số điện thoại: </strong><?php echo $hoa_don['dien_thoai_nguoi_nhan']?></td>
                            <td colspan="2" class="l"><strong>Địa chỉ: </strong><?php echo $hoa_don['dia_chi_nguoi_nhan']?></td>
                          </tr>
                          <tr>
                            <th class="thong_tin" colspan="5">GIỎ HÀNG</th>
                          </tr>
                          <tr>
                            <td colspan="3"><table class="gio_hang">
                                <tr>
                                  <th class="stt">STT</th>
                                  <th class="ten_sp">Tên sản phẩm</th>
                                  <th class="so_luong">Số lượng</th>
                                  <th class="don_gia">Đơn giá (VNĐ)</th>
                                  <th class="thanh_tien">Thành tiền (VNĐ)</th>
                                </tr>
                                <?php
							 	$stt=0;
							 	$ds_sp_da_ban=$dt_xl_chi_tiet_hoa_don->ds_hoa_don($hoa_don['ma']);
								foreach($ds_sp_da_ban as $sp_da_ban){ $stt+=1;
							 ?>
                                <tr>
                                  <td class="stt"><?php echo $stt?></td>
                                  <td class="ten_sp"><?php echo $sp_da_ban['ten_san_pham']?></td>
                                  <td class="so_luong so"><?php echo $sp_da_ban['so_luong']?></td>
                                  <td class="don_gia so"><?php echo number_format($sp_da_ban['don_gia'],2,'.',',')?></td>
                                  <td class="thanh_tien so"><?php echo number_format($sp_da_ban['thanh_tien'],2,'.',',')?></td>
                                </tr>
                                <?php }?>
                                <tr>
                                  <td style="text-align:right; font-weight:bold" class="tong_tien" colspan="6">Tổng tiền: <?php echo number_format($hoa_don['tong_tien'],2,'.',',')?> (VNĐ)</td>
                                </tr>
                              </table></td>
                          </tr>
                        </table>
                      <div><a href="../home/trang-chu.html"><span style="float:right;font-size:15px;padding:20px;"><< Trở về</span></a></div>
                      </div>
                      <div class="cleared"></div>
                    </div>
                    <div class="cleared"></div>
                  </div>
                </div>
                <div class="cleared"></div>
              </div>
              <div class="art-layout-cell art-sidebar2">
                <?php sidebar('right')?>
                <div class="cleared"></div>
              </div>
            </div>
          </div>
          <div class="cleared"></div>
          <?php include '../widgets/footer.php'?>
          <div class="cleared"></div>
        </div>
      </div>
      <div class="cleared"></div>
    </div>
  </div>
</div>
</body>
</html>